{include file="public/header"}
<title>添加</title>
</head>
<body>
<style>
</style>

<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-member-add">
        {if condition="$type==1"}
        <div class="ch-row ch-info-form">
            <p class="flex1">订单状态：</p>
            <div class="flex2 ch-pc-row">
                <select class="form-control goods_category ch-info-select" name="status">
                    <option selected="selected" value="">请选择</option>
                    {volist name='remote' id='v'}
                    <option value="{$v.id}" <?php if($res["status"]==$v['title']){?> selected="selected" <?php }?>>{$v.title}</option>
                    {/volist}</select>
                </select>
                <select class="form-control goods ch-info-select" name="status1">

                    {volist name='go1' id='v'}
                    <option value="{$v.id}" <?php if($res["status1"]==$v['title']){?> selected="selected" <?php }?>>{$v.title}</option>
                    {/volist}</select>
                </select>
                <select class="form-control good" name="status2">
                    {volist name='go2' id='v'}
                    <option value="{$v.id}" <?php if($res["status2"]==$v['title']){?> selected="selected" <?php }?>>{$v.title}</option>
                    {/volist}</select>
                </select>
            </div>
        </div>
        {/if}
        <div class="ch-row ch-info-form">
            <p class="flex1">跟进时间：</p>
            <div class="flex2">
                <input type="text" name="start_time" id="countTimestart" onfocus="selecttime(1)" size="17" class="form-control" readonly 
                value="<?php echo date('Y-m-d H:i:s',$res['th_time'])?>" >
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex1">下次时间：</p>
            <div class="flex2">
                <input type="text" name="end_time" id="countTimeend" onfocus="selecttime(2)" size="17" class="form-control" readonly
                value="<?php echo date('Y-m-d H:i:s',$res['end_time'])?>">
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex1">沟通方式：</p>
            <div class="flex2">
                <select class="form-control" name="mode" >
                    <option value="电话" <?php if($res["mode"]=='电话'){?> selected="selected" <?php }?>>电话</option>
                    <option value="微信" <?php if($res["mode"]=='微信'){?> selected="selected" <?php }?>>微信</option>
                    <option value="其他" <?php if($res["mode"]=='其他'){?> selected="selected" <?php }?>>其他</option>
                </select>
            </div>
        </div>
        <div class="ch-row ch-info-form">
            <p class="flex1">跟进记录：</p>
            <div class="flex2">
                <textarea placeholder="请输入备注"  name="remar" >{$res.remar}</textarea>
            </div>
        </div>
        <input type="hidden" name="through_id" value="{$res.through_id}">
        <input type="hidden" name="order_ids" value="{$res.order_ids}">
        <div class="ch-row ch-info-form">
            <div class="flex1">
                <button class="btn btn-primary radius" type="button" ><i class="Hui-iconfont">&#xe632;</i> 保存信息</button>
            </div>
        </div>

    </form>
</article>
{include file="public/footer"}
<script>
    function selecttime(flag) {
        if (flag == 1) {
            var endTime = $("#countTimeend").val();
            if (endTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd H:m:s', maxDate: endTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd H:m:s'})
            }
        } else {
            var startTime = $("#countTimestart").val();
            if (startTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd H:m:s', minDate: startTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd H:m:s'})
            }
        }
    }
    $('.goods_category').bind("change", function () {
        //向input输入框中赋值
        goods();
    });
    $(".goods").bind("change", function () {
        good()
    });
    function goods() //市
    {
        var parent_ids = $(".goods_category option:selected").val();
        if(parent_ids==''){
            alert('请选择订单状态')
        }
        $.post("{:url('index/order/remote')}", {parent_id: parent_ids}, function (data, textStatus, xhr) {
            var html;
            if (data.length > 0) {
                for (var i = 0; i < data.length; i++) {
                    html += "<option value='" + data[i]['id'] + "'>" + data[i]['title'] + "</option>";
                }

            } else {
                html += "<option value=''>暂无数据</option>";

            }

            $('.goods').html(html);
            good();


        });


    }


    function good() {
        var parent_id = $('.goods').val();
        var html;

        if (parent_id) {
            $.post("{:url('index/order/remote')}", {parent_id: parent_id}, function (data, textStatus, xhr) {

                if (data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        html += "<option value='" + data[i]['id'] + "'>" + data[i]['title'] + "</option>";

                    }
                } else {
                    html += "<option value=''>暂无数据</option>";
                }

                $('.good').html(html);

            });
        } else {
            html += "<option value=''>暂无数据</option>";
            $('.good').html(html);
        }

    }
    $('.radius').click(function () {
        $('#baocun').val($(this).val());
        var src = "{:Url('index/order/through')}";
        $.ajax({
            type: 'POST',
            url: src,
            dataType: 'json',
            data: $('form').serializeArray(),
            success: function (data) {
                var res = JSON.parse(data);
                if (res.code == 200) {
                    parent.location.reload()
                } else {
                    layer.msg(res.msg, {icon: 5, time: 1000});
                }

            },
            error: function (data) {
                console.log(data.msg);
            },
        });


    });

    /**
     * 基建
     */
    $('.js').click(function () {
        var id = $(this).attr('data-id');
        var src = "{:Url('index/order/yuan')}";
        layer.open({
            type: 2,
            area: ['800px', '600px'],
            fix: false,
            maxmin: true,
            shade: 0.4,
            title: '基建添加',
            content: src + '?type=1&order_id=' + id
        });
    });


</script>
</body>
</html>

